﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GeoSketch2.Archaeo
{
    /// <summary>
    /// The soil description sheet, with the park canada template
    /// </summary>
    public class SoilSheetParksCanada : BaseSoilSheet
    {
        #region XMLElementsName
#pragma warning disable 1591
        public const string XML_SoilDescription = "SoilDescription";
        public const string XML_Artefacts = "Artefacts";
        public const string XML_Interpretation = "Interpretation";
        public const string XML_EndWhy = "EndWhy";
#pragma warning restore 1591
        #endregion

        #region Fields
        /// <summary>
        /// The description of the soil
        /// </summary>
        public string SoilDescription;

        /// <summary>
        /// The description of the artefacts
        /// </summary>
        public string Artefacts;

        /// <summary>
        /// The interpretation of the soil
        /// </summary>
        public string Interpretation;

        /// <summary>
        /// Why the unit is closed
        /// </summary>
        public string EndWhy; 
        #endregion

        #region Constructor
        /// <summary>
        /// The soil description sheet, with the park canada template
        /// </summary>
        public SoilSheetParksCanada()
            : this("", "", "", "")
        {
        }

        /// <summary>
        /// The soil description sheet, with the park canada template
        /// </summary>
        /// <param name="SoilDescription">The description of the soil</param>
        /// <param name="Artefacts">The description of the artefacts</param>
        /// <param name="Interpretation">The interpretation of the soil</param>
        /// <param name="EndWhy">Why the unit is closed</param>
        public SoilSheetParksCanada(string SoilDescription, string Artefacts, string Interpretation, string EndWhy)
        {
            this.SoilDescription = SoilDescription;
            this.Artefacts = Artefacts;
            this.Interpretation = Interpretation;
            this.EndWhy = EndWhy;
        }

        /// <summary>
        /// The soil description sheet, with the park canada template
        /// </summary>
        /// <param name="Xr">The dXmlReader to read from</param>
        public SoilSheetParksCanada(XmlReader Xr)
        {
            Xr.ReadToFollowing(XML_SoilDescription);
            this.SoilDescription = Xr.ReadString();

            Xr.ReadToFollowing(XML_Artefacts);
            this.Artefacts = Xr.ReadString();

            Xr.ReadToFollowing(XML_Interpretation);
            this.Interpretation = Xr.ReadString();

            Xr.ReadToFollowing(XML_EndWhy);
            this.EndWhy = Xr.ReadString();

            Xr.ReadEndElement();
        } 
        #endregion

        #region Methods
        public override BaseSoilSheet GetNew()
        {
            return new SoilSheetParksCanada();
        }
        /// <summary>
        /// Shows the form associated to the soil sheet
        /// </summary>
        public override void ShowForm()
        {
            SoilSheetFormParksCanada Form = new SoilSheetFormParksCanada(this);
            Form.Show();
        }

        /// <summary>
        /// Writes the object to a file
        /// </summary>
        /// <param name="Xw">The XmlWriter to write to</param>
        public override void ToFile(XmlWriter Xw)
        {
            Xw.WriteStartElement(BaseSoilSheet.XML_SoilSheet);

            #region Soil Sheet Template
            Xw.WriteStartElement(XML_Template);
            Xw.WriteString(this.GetType().FullName);
            Xw.WriteEndElement();
            #endregion

            #region Soil Description
            Xw.WriteStartElement(XML_SoilDescription);
            Xw.WriteString(SoilDescription);
            Xw.WriteEndElement();
            #endregion

            #region Artefacts
            Xw.WriteStartElement(XML_Artefacts);
            Xw.WriteString(Artefacts);
            Xw.WriteEndElement();
            #endregion

            #region Interpretation
            Xw.WriteStartElement(XML_Interpretation);
            Xw.WriteString(Interpretation);
            Xw.WriteEndElement();
            #endregion

            #region EndWhy
            Xw.WriteStartElement(XML_EndWhy);
            Xw.WriteString(EndWhy);
            Xw.WriteEndElement();
            #endregion

            Xw.WriteEndElement();
        } 
        #endregion
    }
}
